<template>
  <div class="c-vote-result">
    <!-- <a-row :gutter="24">
      <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="请选择要批量发布的用户">
        <a-select ref="select" @change="handleChange">
          <a-select-option
            v-for="batch in batchs"
            :key="batch"
            :value="batch"
            style="width:200px"
          >{{batch}}</a-select-option>
        </a-select>
      </a-form-item>
    </a-row>

    <br /> -->
    <table v-if="isLoaded">
      <tbody>
        <tr>
          <th>姓名</th>
          <th>打分人数</th>
          <th>总分</th>
          <th>最高分</th>
          <th>最低分</th>
          <th>平均分</th>
          <!-- <th>打分详情</th> -->
          <th>备注</th>
        </tr>
        <tr>
          <td v-if="noAuth" colspan="8" style="text-align:center">无权限查看</td>
        </tr>
        <tr v-for="user in cpdList" :key="user.name">
          <td>{{user.name}}</td>
          <td>{{user.voteCount}}</td>
          <td>{{user.totalScore}}</td>
          <td>{{user.maxScore}}</td>
          <td>{{user.minScore}}</td>
          <td>{{user.avgScore}}</td>
          <!-- <td>
            <div v-for="(s,index) in user.scoreDetailArr" :key="index">{{s}}</div>
          </td>-->
          <td>
            <div v-for="(r,index) in user.remarkDetailArr" :key="index">{{r}}</div>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>
<script>
import api from '~/assets/js/common/api'
export default {
  data() {
    return {
      isLoaded: false,
      noAuth: true,
      batchs: ['201903SHEJI', '201904SHEJI'],
      list: [
        {
          name: '',
          voteCount: 0,
          totalScore: 0,
          avgScore: 0,
          maxScore: 0,
          minScore: 0,
          scoreDetail: '',
          remarkDetail: ''
        }
      ]
    }
  },
  computed: {
    cpdList() {
      this.list &&
        this.list.forEach(ele => {
          ele.scoreDetailArr = ele.scoreDetail.split(',')
          ele.remarkDetailArr = ele.remarkDetail.split(',')
        })
      return this.list
    }
  },
  mounted() {
    this.queryVoteResult()
  },
  methods: {
    async queryVoteResult() {
      let { data } = await this.$axios.get(api.vote.result)
      this.list = data.result.list
      if (data.state === 0) {
        this.noAuth = false
      }
      setTimeout(() => {
        this.isLoaded = true
      }, 300)
    },
    handleChange(e) {}
  }
}
</script>
<style lang="scss" scoped>
.c-vote-result {
  background-color: #fff;
  margin-top: 20px;
  padding: 20px;
}
table {
  min-width: 50%;
}
</style>